package net.qiqbframework.modelling.command.fetching;

import net.qiqbframework.modelling.command.BizIdentifierVoucherMember;
import net.qiqbframework.modelling.domain.Aggregate;

import java.util.List;
import java.util.Optional;


public class PreAnnotatedCommand<C, A> implements Command<C, A> {

    private final C command;

    private final AggregateCommandModel<C, A> commandModel;

    public PreAnnotatedCommand(C command, AggregateCommandModel<C, A> commandModel) {
        this.command = command;
        this.commandModel = commandModel;
    }

    @Override
    public C commandObject() {
        return command;
    }

    @Override
    public AggregateCommandModel<C, A> commandModel() {
        return commandModel;
    }

    @Override
    public Optional<Aggregate<A>> obtainAggregate() {

        return Optional.ofNullable(commandModel.obtainAggregate(command));
    }


    @Override
    public List<BizIdentifierVoucherMember> allBizIdentifierVoucherMembers() {
        return List.of();
    }
}
